import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/application/emergency/emergency_plan_organization_entity.dart';
import 'package:enterprise_v6_app/app/data/common/tree_node_bean.dart';

import 'package:enterprise_v6_app/app/data/entities/application/emergency/organization_role_entity.dart';


EmergencyPlanOrganizationEntity $EmergencyPlanOrganizationEntityFromJson(Map<String, dynamic> json) {
  final EmergencyPlanOrganizationEntity emergencyPlanOrganizationEntity = EmergencyPlanOrganizationEntity();
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    emergencyPlanOrganizationEntity.companyCode = companyCode;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    emergencyPlanOrganizationEntity.createBy = createBy;
  }
  final String? createById = jsonConvert.convert<String>(json['createById']);
  if (createById != null) {
    emergencyPlanOrganizationEntity.createById = createById;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    emergencyPlanOrganizationEntity.createDate = createDate;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    emergencyPlanOrganizationEntity.deleted = deleted;
  }
  final String? departmentName = jsonConvert.convert<String>(json['departmentName']);
  if (departmentName != null) {
    emergencyPlanOrganizationEntity.departmentName = departmentName;
  }
  final String? emergencyId = jsonConvert.convert<String>(json['emergencyId']);
  if (emergencyId != null) {
    emergencyPlanOrganizationEntity.emergencyId = emergencyId;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    emergencyPlanOrganizationEntity.id = id;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    emergencyPlanOrganizationEntity.parentId = parentId;
  }
  final String? planId = jsonConvert.convert<String>(json['planId']);
  if (planId != null) {
    emergencyPlanOrganizationEntity.planId = planId;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    emergencyPlanOrganizationEntity.type = type;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    emergencyPlanOrganizationEntity.updateBy = updateBy;
  }
  final String? updateById = jsonConvert.convert<String>(json['updateById']);
  if (updateById != null) {
    emergencyPlanOrganizationEntity.updateById = updateById;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    emergencyPlanOrganizationEntity.updateDate = updateDate;
  }
  final List<EmergencyPlanOrganizationEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<EmergencyPlanOrganizationEntity>(e) as EmergencyPlanOrganizationEntity).toList();
  if (children != null) {
    emergencyPlanOrganizationEntity.children = children;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    emergencyPlanOrganizationEntity.isExpand = isExpand;
  }
  final bool? isSelected = jsonConvert.convert<bool>(json['isSelected']);
  if (isSelected != null) {
    emergencyPlanOrganizationEntity.isSelected = isSelected;
  }
  final List<OrganizationRoleEntity>? userList = (json['userList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<OrganizationRoleEntity>(e) as OrganizationRoleEntity).toList();
  if (userList != null) {
    emergencyPlanOrganizationEntity.userList = userList;
  }
  return emergencyPlanOrganizationEntity;
}

Map<String, dynamic> $EmergencyPlanOrganizationEntityToJson(EmergencyPlanOrganizationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyCode'] = entity.companyCode;
  data['createBy'] = entity.createBy;
  data['createById'] = entity.createById;
  data['createDate'] = entity.createDate;
  data['deleted'] = entity.deleted;
  data['departmentName'] = entity.departmentName;
  data['emergencyId'] = entity.emergencyId;
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['planId'] = entity.planId;
  data['type'] = entity.type;
  data['updateBy'] = entity.updateBy;
  data['updateById'] = entity.updateById;
  data['updateDate'] = entity.updateDate;
  data['children'] = entity.children.map((v) => v.toJson()).toList();
  data['isExpand'] = entity.isExpand;
  data['isSelected'] = entity.isSelected;
  data['userList'] = entity.userList.map((v) => v.toJson()).toList();
  return data;
}

extension EmergencyPlanOrganizationEntityExtension on EmergencyPlanOrganizationEntity {
  EmergencyPlanOrganizationEntity copyWith({
    String? companyCode,
    String? createBy,
    String? createById,
    String? createDate,
    String? deleted,
    String? departmentName,
    String? emergencyId,
    String? id,
    String? parentId,
    String? planId,
    int? type,
    String? updateBy,
    String? updateById,
    String? updateDate,
    List<EmergencyPlanOrganizationEntity>? children,
    bool? isExpand,
    bool? isSelected,
    List<OrganizationRoleEntity>? userList,
  }) {
    return EmergencyPlanOrganizationEntity()
      ..companyCode = companyCode ?? this.companyCode
      ..createBy = createBy ?? this.createBy
      ..createById = createById ?? this.createById
      ..createDate = createDate ?? this.createDate
      ..deleted = deleted ?? this.deleted
      ..departmentName = departmentName ?? this.departmentName
      ..emergencyId = emergencyId ?? this.emergencyId
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..planId = planId ?? this.planId
      ..type = type ?? this.type
      ..updateBy = updateBy ?? this.updateBy
      ..updateById = updateById ?? this.updateById
      ..updateDate = updateDate ?? this.updateDate
      ..children = children ?? this.children
      ..isExpand = isExpand ?? this.isExpand
      ..isSelected = isSelected ?? this.isSelected
      ..userList = userList ?? this.userList;
  }
}
